package com.clock.web.controller.shop;

import com.clock.common.annotation.Log;
import com.clock.common.core.controller.BaseController;
import com.clock.common.core.domain.AjaxResult;
import com.clock.common.core.page.TableDataInfo;
import com.clock.common.enums.BusinessType;

import com.clock.common.utils.poi.ExcelUtil;
import com.clock.shop.domain.ShopAppointed;
import com.clock.shop.domain.vo.AppointedVo;
import com.clock.shop.service.IShopAppointedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 预约Controller
 * 
 * @author ruoyi
 * @date 2024-10-11
 */
@RestController
@RequestMapping("/shop/appointed")
public class ShopAppointedController extends BaseController
{
    @Autowired
    private IShopAppointedService shopAppointedService;

    /**
     * 查询预约列表
     */
    @PreAuthorize("@ss.hasPermi('shop:appointed:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppointedVo appointedVo)
    {
        startPage();
        List<AppointedVo> list = shopAppointedService.selectShopAppointedList(appointedVo);
        return getDataTable(list);
    }

    /**
     * 导出预约列表
     */
    @PreAuthorize("@ss.hasPermi('shop:appointed:export')")
    @Log(title = "预约", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppointedVo appointedVo)
    {
        List<AppointedVo> list = shopAppointedService.selectShopAppointedList(appointedVo);
        ExcelUtil<AppointedVo> util = new ExcelUtil<AppointedVo>(AppointedVo.class);
        util.exportExcel(response, list, "预约数据");
    }

    /**
     * 获取预约详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:appointed:query')")
    @GetMapping(value = "/{appointedId}")
    public AjaxResult getInfo(@PathVariable("appointedId") Long appointedId)
    {
        return success(shopAppointedService.selectShopAppointedByAppointedId(appointedId));
    }

    /**
     * 新增预约
     */
    @PreAuthorize("@ss.hasPermi('shop:appointed:add')")
    @Log(title = "预约", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppointedVo appointedVo)
    {
        return toAjax(shopAppointedService.insertShopAppointed(appointedVo));
    }

    /**
     * 修改预约
     */
    @PreAuthorize("@ss.hasPermi('shop:appointed:edit')")
    @Log(title = "预约", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppointedVo appointedVo)
    {
        return toAjax(shopAppointedService.updateShopAppointed(appointedVo));
    }

    /**
     * 删除预约
     */
    @PreAuthorize("@ss.hasPermi('shop:appointed:remove')")
    @Log(title = "预约", businessType = BusinessType.DELETE)
	@DeleteMapping("/{appointedIds}")
    public AjaxResult remove(@PathVariable Long[] appointedIds)
    {
        return toAjax(shopAppointedService.deleteShopAppointedByAppointedIds(appointedIds));
    }
}
